package com.lengtouzai.databaseexp.view.educationalexperience;

import com.lengtouzai.databaseexp.entity.EducationalExperience;
import com.lengtouzai.databaseexp.entity.User;
import com.lengtouzai.databaseexp.view.main.MainView;
import com.vaadin.flow.router.Route;
import io.jmix.core.security.CurrentAuthentication;
import io.jmix.flowui.model.InstanceContainer;
import io.jmix.flowui.view.*;
import org.springframework.beans.factory.annotation.Autowired;

@Route(value = "educationalExperiences/:id", layout = MainView.class)
@ViewController("exp_EducationalExperience.detail")
@ViewDescriptor("educational-experience-detail-view.xml")
@EditedEntityContainer("educationalExperienceDc")
public class EducationalExperienceDetailView extends StandardDetailView<EducationalExperience> {
    @ViewComponent
    private InstanceContainer<EducationalExperience> educationalExperienceDc;
    @Autowired
    private CurrentAuthentication currentAuthentication;

    @Subscribe
    public void onReady(final ReadyEvent event) {
        educationalExperienceDc.getItem().setUser((User) currentAuthentication.getUser());
    }
}